#include "SkinManager.h"
#include "SkinXML.h"
#include "SkinObjManager.h"

CSkinManager* CSkinManager::m_pSkinMgr = NULL;

CSkinManager::CSkinManager( void )
{
}


CSkinManager::~CSkinManager( void )
{
    CSkinObjManager* pSkinObjMgr = CSkinObjManager::GetHinstance();

    if ( NULL != pSkinObjMgr )
    {
        delete pSkinObjMgr;
        pSkinObjMgr = NULL;
    }
}

CSkinManager* CSkinManager::GetSkinMgr()
{
    if ( NULL == m_pSkinMgr )
    {
        m_pSkinMgr = new CSkinManager();
    }

    return m_pSkinMgr;
}

BOOL CSkinManager::LoadSkinFile( LPCTSTR lpszSkinName, SKIN_SRC_TYPE skinSrcType/* =SKIN_TYPE_XML */ )
{
    BOOL bRet = FALSE;
    CSkinFile* pSkinFile = GetSkinFile( lpszSkinName, skinSrcType );

    if ( NULL != pSkinFile )
    {
        if ( ( pSkinFile->LoadSkinFile() ) && ( pSkinFile->Parse() ) )
        {
            bRet = TRUE;
        }

        delete pSkinFile;
        pSkinFile = NULL;
    }

    return bRet;
}

CSkinFile* CSkinManager::GetSkinFile( LPCTSTR lpszSkinName, SKIN_SRC_TYPE skinSrcType/* =SKIN_TYPE_XML */ )
{
    CSkinFile* pSkinFile = NULL;

    if ( SKIN_TYPE_XML == skinSrcType )
    {
        pSkinFile = new CSkinXML( lpszSkinName );
    }

    return pSkinFile;
}